package com.outstanding.ifml;

import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.outstanding.ifml.exception.IFMLException;


/**
 *  一夫实体，多个Item 的集合
 * @author chenzhixuan
 *
 */
public class IFML {

	private List<Item> ifList = new ArrayList<Item>();

	

	private List<Item> getIfList() {
		return ifList;
	}




	public void addIF(Item item) {
		this.ifList.add(item);
	}

	
	
	
	public void wirte(OutputStream out) throws IOException {
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
		bw.write(this.toString());
	}
	
	
	
	

	public String toString() {
		StringBuffer sb = new StringBuffer();
		if (this.ifList != null) {
			for (Item iF : this.ifList) {
				sb.append(iF.toString());
			}
		}
		return sb.toString();
	}
	
	public void sort() {
		Collections.sort(ifList);
		for (Item iF : this.ifList) {
			iF.sort();
		}
	}
	


}
